package com.tcwlkj.uuService.ui;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.WindowManager;

import com.tcwlkj.uuService.R;
import com.tcwlkj.uuService.adapter.GalleryAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/9/30 0030.
 */

public class HonorsActivity extends BaseActivity {
    RecyclerView mRecyclerView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_honors);
        ButterKnife.bind(this);
        changeTitle("荣誉榜");
        initRecyclerView();
    }

    private void initRecyclerView() {
        mRecyclerView = $(R.id.honor_title);
        //设置布局管理器
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        mRecyclerView.addItemDecoration(new DividerItemDecoration(
                this, DividerItemDecoration.HORIZONTAL));
        mRecyclerView.setLayoutManager(linearLayoutManager);
        List<String> bigList = new ArrayList<String>();
        bigList.add("好评");
        bigList.add("收入");
        List<String> smallList = new ArrayList<String>();
        smallList.add("排行榜");
        smallList.add("排行榜");
        WindowManager wm = (WindowManager) this
                .getSystemService(Context.WINDOW_SERVICE);
        int width = wm.getDefaultDisplay().getWidth();
        GalleryAdapter mAdapter = new GalleryAdapter(this, bigList, smallList, width / bigList.size());
        mAdapter.setOnItemClickLitener(new GalleryAdapter.OnItemClickLitener() {
            @Override
            public void onItemClick(View view, int position) {
                setPagerChaned(position);
            }
        });
        mRecyclerView.setAdapter(mAdapter);
    }

    public interface OnPagerChangedListener {
        void OnPagerChangedListener(int position);
    }

    OnPagerChangedListener mOnPagerChangedListener;

    public void setPagerchangedListener(OnPagerChangedListener listener) {
        mOnPagerChangedListener = listener;
    }

    public void setPagerChaned(int position) {
        mOnPagerChangedListener.OnPagerChangedListener(position);
    }
}
